package leetcode;

/**
 * @author ht
 * @create 2025-07-09 23:11
 * @desc
 **/
public class T28 {

    public static int strStr(String haystack, String needle) {
        String s = String.valueOf(needle.charAt(0));
        for (int i = 0; i < haystack.length(); i++) {
            String start = String.valueOf(haystack.charAt(i));
            if(start.equals(s) && i + needle.length() <= haystack.length() && haystack.substring(i, i + needle.length()).equals(needle)) {
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        System.out.println(strStr("leetcode", "leeto"));
    }
}
